package com.dsg.kf.socket.service;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import com.dsg.kf.socket.context.MessageConcurrentLinkedQueue;
import com.dsg.kf.socket.message.MessageBase;

/**
 * aop拦截 所有进入service等待处理的消息 放入queue队列
 * @author pacy.pan
 *
 */
@Aspect
@Component
public class InnerDbMessageAop {

	@Pointcut("execution(* com.dsg.kf.socket.service.*.doSocketService(..))")
	private void beforeMessage() {
	}// 定义一个切入点

	@Before("beforeMessage()")
	public void doBefore(JoinPoint joinPoint) {
		 Object[] args = joinPoint.getArgs();
		 Object obj=args[0];
		 if(obj!=null && (obj instanceof MessageBase)){
			 MessageBase base =(MessageBase)obj;
			 MessageConcurrentLinkedQueue.offerMessageQueue(base);
		 }
	}
}
